package com.njtoyo.taxi.admin.rest.controller.data;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.DriverAllowancePresenter;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.DriverPeakAllowancePresenter;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.DriverRecommendAllowancePresenter;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.DriverRedPacketAllowancePresenter;
import com.njtoyo.taxi.admin.rest.wrapper.data.allowance.AllowanceChartWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.data.allowance.AllowanceWrapper;
import com.njtoyo.taxi.admin.service.data.AllowanceDriverService;
import com.taxi.entity.common.RestResult;
import com.njtoyo.taxi.entity.backend.AdminUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;

@RequestMapping("/data/allowance/driver")
@Api(value = "司机补贴", tags = "补贴统计-司机")
@RestController
public class AllowanceDriverController {

    @Qualifier("allowanceDriverServiceCacheImpl")
    @Autowired
    private AllowanceDriverService allowanceDriverService;

    @GetMapping("")
    @ApiOperation(value = "司机补贴", notes = "权限：allowance")
    @ApiOperationSupport(order = 10)
    @PermissionScope(names = {"allowance"})
    public RestResult<DriverAllowancePresenter> driver(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceDriverService.proportion(adminUser, wrapper);
    }

    @GetMapping("/red_packet")
    @ApiOperation(value = "司机接单红包", notes = "权限：allowance")
    @ApiOperationSupport(order = 11)
    @PermissionScope(names = {"allowance"})
    public RestResult<DriverRedPacketAllowancePresenter> driverRedPacket(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceDriverService.redPacket(adminUser, wrapper);
    }

    @GetMapping("/recommend")
    @ApiOperation(value = "司机推广", notes = "权限：allowance")
    @ApiOperationSupport(order = 12)
    @PermissionScope(names = {"allowance"})
    public RestResult<DriverRecommendAllowancePresenter> driverRecommend(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceDriverService.recommend(adminUser, wrapper);
    }

    @GetMapping("/peak")
    @ApiOperation(value = "司机高峰奖励", notes = "权限：allowance")
    @ApiOperationSupport(order = 13)
    @PermissionScope(names = {"allowance"})
    public RestResult<DriverPeakAllowancePresenter> driverPeak(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceDriverService.peak(adminUser, wrapper);
    }

    @GetMapping("/chart/proportion")
    @ApiOperation(value = "司机补贴趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 13)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<DriverAllowancePresenter>> chartProportion(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceDriverService.chartProportion(adminUser, wrapper);
    }

    @GetMapping("/chart/red_packet")
    @ApiOperation(value = "司机接单红包趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 11)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<DriverRedPacketAllowancePresenter>> chartDriverRedPacket(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceDriverService.chartRedPacket(adminUser, wrapper);
    }

    @GetMapping("/chart/recommend")
    @ApiOperation(value = "司机推广 - 趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 12)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<DriverRecommendAllowancePresenter>> chartDriverRecommend(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceDriverService.chartRecommend(adminUser, wrapper);
    }
}
